﻿@using ST = EmoneyWeiXinCommon.StringTools;

@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>View1</title>
    <link href="@ST.GetStaticFile("Models/css/basic.css")" rel="stylesheet" type="text/css">
    <link href="@ST.GetStaticFile("Models/css/font/iconfont.css")" rel="stylesheet">
    <script type="text/javascript" src="@ST.GetStaticFile("Scripts/jquery-1.8.3.min.js")"></script>
    <script type="text/javascript" src="@ST.GetStaticFile("Scripts/Common.js")"></script>
    <link href="@ST.GetStaticFile("My97DatePicker/skin/WdatePicker.css")" rel="stylesheet" />
    <script src="@ST.GetStaticFile("My97DatePicker/WdatePicker.js")"></script>
    <link href="@ST.GetStaticFile("Models/css/tree_themes/SimpleTree.css")" rel="stylesheet" />
    <script src="@ST.GetStaticFile("Scripts/SimpleTree.js")"></script>
</head>
<body>
    <div class="right">
        <h3>资讯数据管理</h3>
        <!--manage-->
        <div class="manage">
            <!--manage_top-->
            <div class="manage_top">
                @*<ul class="manage_top_ul">
            </ul>*@
                <div class="manage_register">
                    <p id="pType">
                    </p>
                    <p>
                        <span>发布时间：</span>
                        <input type="text" id="txtStart" onfocus="WdatePicker()" class="manage_register_text" value="@ViewBag.DfBeginDate">
                        <span class="manage_register_font">至</span><input style="display: none" id="hidid" type="text" >
                        <input type="text" id="txtEnd" onfocus="WdatePicker()" class="manage_register_text" value="@ViewBag.DfEndDate">
                    </p>
                </div>
                <div class="manage_register">
                    <p class="manage_register_p"><span>标题：</span><input type="text" id="txtTitle" placeholder="支持标题模糊搜索"></p>
                </div>
                <p class="manage_add">
                    <a id="btnQuery">查询</a>
                </p>
            </div>
            <!--manage_top end-->
            <p class="manage_line"></p>
            <!--manage_bottom-->
            <div class="manage_bottom">
                <table border="0" cellpadding="0" cellspacing="0" width="100%" id="tablelist">
                    <tr>
                        <th><span>选择</span></th>
                        <th><span>编号</span></th>
                        <th><span>标题</span></th>
                        <th><span>栏目</span></th>
                        <th><span>发布时间</span></th>
                        <th><span>更新时间</span></th>
                        <th><span>是否发布</span></th>
                    </tr>
                    <tbody id="dvList"></tbody>
                </table>
                <div class="manage_page" id="manage_page">
                </div>

                <p class="manage_add">
                    <a id="btnSave">确定</a>
                </p>
            </div>

            <!--manage_bottom end-->
        </div>
        <!--manage end-->
    </div>

</body>
</html>


<script type="text/javascript">
    var weixinid = "@ViewBag.weixinid";
    var pageIndex = 1;
    var pageSize = 10;
    var pageCount = 1;
    var totalCount = 0;
    $(document).ready(function () {
        memutype(function (result) { if (result == "1") gotoPage(); });
        $("#btnQuery").click(function () {
            gotoPage();
        });


        $("#btnSave").click(function () {
            var newsreportids = "";
            var titles = "";
            var menunames="";
            var updatetimes="";
            $("#tablelist tr td input").each(function (n, i) {
                if ($(this).attr("checked") != undefined) {
                    newsreportids += $(this).attr("newsreportid") + "^";
                    titles += $(this).attr("title") + "^";
                    menunames += $(this).attr("menuname") + "^";
                    updatetimes += $(this).attr("updatetime") + "^";
                }
            })

            parent.UpdatePD(newsreportids, titles, menunames, updatetimes);
        });
    });

    var ajaxdata = {};
    function gotoPage() {
        ajaxdata["pindex"] = pageIndex;
        ajaxdata["psize"] = pageSize;
        ajaxdata["memutype"] = $("#drpNewsType").val();
        ajaxdata["pubdate1"] = $("#txtStart").val();
        ajaxdata["pubdate2"] = $("#txtEnd").val();
        ajaxdata["title"] = $("#txtTitle").val();
        ajaxdata["weixinid"] = weixinid;
        $.ajax({
            url: "@ST.GetTrendsFile("Report/QueryNewsReportList2")",
            type: "POST",
            async: true,
            data: ajaxdata,
            beforeSend: function () {
                //showLoading();
            },
            complete: function () {
                //iddenLoading();
            },
            success: function (data) {
                if (data != "" && data != null && data != undefined) {
                    var arrData = data.split("^");
                    totalCount = arrData[0];
                    data = arrData[1];
                    var d = eval(data);
                    var html = "";
                    if (d != "" && d != null && d != undefined) {
                        for (var i = 0; i < d.length; i++) {
                            html += "<tr>";
                            html += getSelectedTd(d[i]["ID"], d[i]["title"], d[i]["mtitle"], d[i]["updatetime"].replace(/T/g, " ")) + getTxtTd(d[i]["ID"]) + getTxtTd(d[i]["title"]) + getTxtTd(d[i]["mtitle"]) + getTxtTd(d[i]["pubDate"].replace(/T/g, " "));
                            html += getTxtTd(d[i]["updatetime"].replace(/T/g, " ")) + getTxtTd(d[i]["PubStatusName"]);
                            html += '</tr>';
                        }
                    }
                    $("#dvList").html(html);
                    PageCountHtml();
                }
                else {
                    $("#dvList").html("没有查询到相关数据！");
                }
            },
            error: function (jqXHR, textStatus, errorThrown) {
                //alert(errorThrown);
            }
        });
    }
    function getSelectedTd(newsreportid, title, menuname, upatetime) {
        return '<td><input  type="checkbox" id="cbNews" name="news" newsreportid="' + newsreportid + '" title="' + title + '" menuname="' + menuname + '" updatetime="' + upatetime + '" /></td>';
    }
    //function getSelectedTd(newsreportid) {
    //    return '<td><input  type="radio" id="cbNews" name="news" newsreportid="' + newsreportid + '" /></td>';
    //}
    function getTxtTd(s) {
        return '<td><span>' + s + '</span></td>';
    }

    function memutype(fn) {
        $.ajax({
            url: "@ST.GetTrendsFile("Report/GetMemuTypeList")",
            type: "POST",
            async: true,
            data: {},
            beforeSend: function () {
                //showLoading();
            },
            complete: function () {
                // hiddenLoading();
            },
            success: function (data) {
                if (data != null && data != "" && data != undefined) {
                    var d = eval(data);
                    $("#pType").html("");
                    var html = '<span>栏目：</span><select id="drpNewsType" ><option value="-1">全部</option>';
                    for (var i = 0; i < d.length; i++) {
                        html += ' <option value="' + d[i]["everyKey"] + '">' + d[i]["title"] + '</option>';
                    }
                    html += '</select>';
                    $("#pType").append(html);
                    fn('1');
                }
            },
            error: function (jqXHR, textStatus, errorThrown) {
                //alert(errorThrown);
            }
        });
    }
    //翻页
    function PageCountHtml() {
        pageCount = Math.ceil(totalCount / pageSize);
        if (pageCount == 0) {
            pageCount = 1;
        }
        $("#manage_page").html(PageHtml(pageIndex, pageCount));
        $("#manage_page .manage_page_right").click(function () {
            pageIndex = parseInt($("#txtPageNum").val()) + parseInt($(this).attr("tname"));
            $("#manage_page").html(PageHtml(pageIndex, pageCount));
            gotoPage();
        });
        $("#manage_page .tiaozhuan").click(function () {
            var pageNum = $("#txtPageNum").val();
            try {
                pageIndex = parseInt(pageNum);
            } catch (e) {
                alert("请输入数字");
                return false;
            }

            if (pageNum > 0 && pageNum <= pageCount) {
                $("#manage_page").html(PageHtml(pageIndex, pageCount));
                gotoPage();
            }
            else {
                alert("当前数字超出范围");
                return false;
            }
        });
    }
</script>



